<template>
  <div class="container">
    <van-nav-bar @click-left="back">
      <van-icon size="20" name="arrow-left" slot="left" color="rgb(150, 151, 153)"/>
      <p slot="title" style="font-size: 14px">反馈信息</p>
    </van-nav-bar>
    <van-field
        v-model="message"
        rows="2"
        autosize
        type="textarea"
        maxlength="50"
        placeholder="请输入您要反馈的问题"
        show-word-limit
    />
    <van-button @click="userback" type="danger" block round style="margin: 5px auto;width: 95%">问题反馈</van-button>
  </div>
</template>

<script>
import { requestPostUserBack } from '../../api/user'

export default {
  name: 'FeedBack',
  data () {
    return {
      message: ''
    }
  },
  methods: {
    back () {
      this.$router.back()
    },
    userback () {
      if (!this.message.length) {
        this.$toast.fail({
          message: '输入不得为空'
        })
        return
      }
      requestPostUserBack(this.message).then(res => {
        setTimeout(() => {
          this.$toast.success({
            duration: 2000,
            message: (res.msg)
          })
          this.message = ''
          this.$router.back()
        }, 500)
      })
    }
  }
}
</script>

<style scoped>
.container {
  background: #fff;
  padding: 1px;
}
</style>
